#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <unistd.h>

int main(int argc, char** argv) {

    /** 1. 向量对矩阵赋值  **/
    std::cout << "========================= 1 =========================" << std::endl;
    Eigen::Vector3d vector_01(1, 2, 3);
    Eigen::Matrix<double, 4, 4> matrix_01 = Eigen::Matrix<double, 4, 4>::Zero();

    matrix_01.row(0).head(3) = vector_01.transpose();
    matrix_01.row(1).head(3) = vector_01; // 操作等同
    std::cout << matrix_01 << std::endl;

    /** 2. 逐元素操作 **/
    std::cout << "========================= 2 =========================" << std::endl;
    Eigen::Vector3d vector_02(1.1, 2.4, 3.5);

    // std::cout << vector_02.round() << std::endl;    // 错误，只有array()后才能逐元素操作
    std::cout << vector_02.array().round().transpose() << std::endl;
    std::cout << vector_02.array().ceil().transpose() << std::endl;
    std::cout << vector_02.array().floor().transpose() << std::endl;

    /** 3. 强制类型转换 **/
    std::cout << "========================= 3 =========================" << std::endl;
    Eigen::Vector3d vector_03(1.1, 2.4, 3.5);
    std::cout << vector_03.cast<int>().transpose() << std::endl;



    return 0;
}